package be.fedict.drupaltest.parts.installation;

import be.fedict.drupaltest.parts.BasePage;
import java.util.List;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

/**
 * Drupal installation wizard language page.
 * 
 * @author Bart Hanssens
 */
public class ChooseLanguagePage extends BasePage {
    @FindBy(id = "install-select-locale-form")
    private WebElement form;
    @FindBy(name = "locale")
    private List<WebElement> locales;
   
    /**
     * Get a specific radio button (language) element.
     * 
     * @param locale language
     * @return element or null
     */
    public WebElement getLocaleElement(String locale) {
        return getRadioElement(locales, locale);
    }
    
    /**
     * Select the Drupal installation language
     * 
     * @param locale language
     */
    public void selectLanguage(String locale) {
        WebElement el = getLocaleElement(locale);
        el.click();
    }
    
    /**
     * Submit form
     */
    public void submit() {
        form.submit();
    }
}
